import {get, post} from "@/api/base/http";
import {ApiUri} from "@/api/base/ApiPath";
// @ts-ignore
import Utils from "@/vue2-flow/src/utils/Common";

let ApiPath = new ApiUri();

export class UserComponent {

    static Gets = (id: Number) => {
        return get(ApiPath.UserComponent.LIST + '/' + id);
    }

    static Save = (ProjectId: Number, Page: string, Json: string) => {
        return post(ApiPath.UserComponent.ROOT,
            {ProjectId: ProjectId, Type: Page, ComponentJson: Json})
            .then(res => {
                if (res?.IsSuccess) {
                    Utils.SetUserPageComponentCache(Page, Json)
                }
                return res;
            });
    }
}
